package com.example.controller;

import com.example.service.NotifyExampleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/notify-example")
public class NotifyExampleController {

    @Autowired
    private NotifyExampleService notifyExampleService;

    @GetMapping("/wait")
    public String waitForCondition() {
        new Thread(() -> notifyExampleService.waitForCondition()).start();
        return "线程正在等待条件满足...";
    }

    @GetMapping("/notify")
    public String notifyCondition() {
        new Thread(() -> notifyExampleService.notifyCondition()).start();
        return "已通知条件满足，等待线程将被唤醒...";
    }
}
